﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System; 

#endregion

namespace ScrumTable.UI.ViewModel.Dynamic
{
    /// <summary>
    /// 
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
    public class DynamicValueResolverAttribute : Attribute
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private readonly Type _dynamicResolverType;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// 
        /// </summary>
        public Type DynamicResolverType
        {
            get { return _dynamicResolverType; }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dynamicResolverType"></param>
        public DynamicValueResolverAttribute(Type dynamicResolverType)
        {
            _dynamicResolverType = dynamicResolverType;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IDynamicValueResolver TryCreateContext()
        {
            if(_dynamicResolverType==null)
            {
                return null;
            }
            return (IDynamicValueResolver)Activator.CreateInstance(_dynamicResolverType);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}